<?php
/**
 * Class AgentAddress
 * Desc  代理地址Controller
 * Create on 2021/8/26 14:56
 * Create by wangyafang
 */

namespace app\api\controller\xyb;


use app\api\model\xyb\AgentAddressGroup;

class AgentAddress extends Base
{
    protected $noNeedLogin = ['index'];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['*'];

    public function _initialize(){
        parent::_initialize();
    }

    public function index()
    {
        if(!$this->request->isPost()) {
            $this->error('请求类型错误');
        }

        $data = (new AgentAddressGroup())->alias('group')
            ->where([
                'group.agent_id'=>$this->request->param('agent_id'),
                'group.status'=>'normal',
            ])->order('group.weigh desc,group.id desc')
            ->field('group.id,group.name')
            ->with(['address'])
            ->select();
        $this->success('请求成功',$data);
    }
}